const initState = {
  num: 0,
}

function reducer(state = initState, action) {
  switch (action.type) {
    case "INCREMENT":
      return {
        ...state,
        num: state.num + 1,
      }
    case "INCREMENTPAYLOAD":
      return {
        ...state,
        num: state.num + action.n,
      }
    case "DECREMENT":
      return {
        ...state,
        num: state.num - 1,
      }
    default:
      return state
  }
}

export default reducer
